﻿//https://leetcode.cn/problems/assign-cookies/

class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s)
    {
        sort(g.begin(), g.end());
        sort(s.begin(), s.end());

        int ret = 0;
        int m = g.size(), n = s.size();
        for (int i = 0, j = 0; i < m && j < n; i++, j++)
        {
            //找饼干
            while (j < n && s[j] < g[i]) j++;

            if (j < n) ret++;
        }

        return ret;

    }
};